// store/modules/auth.js（用户认证状态）
export default {
    state: () => ({
      token: localStorage.getItem('token') || '',
      role: localStorage.getItem('role') || ''
    }),
    mutations: {
      setAuth(state, { token, role }) {
        state.token = token;
        state.role = role;
        localStorage.setItem('token', token);
        localStorage.setItem('role', role);
      },
      clearAuth(state) {
        state.token = '';
        state.role = '';
        localStorage.removeItem('token');
        localStorage.removeItem('role');
      }
    }
  };